package Service;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import DAO.userDAO;
import HibernateUtilsforBM.SFactoryGenerator;
import Model.adminUserlist;
import Model.user;

public class adminService {
	//列出所有用户
	public List<adminUserlist> UserListService(){
		Session session = SFactoryGenerator.getSession();
		//开启事务
		Transaction tx = session.beginTransaction();
		List<user> list1 = null;
		List<adminUserlist> list2 = null; 
		try{
				list1 = userDAO.findAll(session);
				tx.commit();
			}catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
				tx.rollback();
			}finally{
				session.close();
			}
		for(int i=0;i<list1.size();i++)
			list2.add(new adminUserlist(list1.get(i)));
		return list2;
	}
}
